@inherits PageBase
@using BlazorApp.Pages.Namespace
@using k8s.Models
@typeparam            TItem

<GridRow >
    <GridCol Span="6">
        <div style="@_style">@Title</div>
    </GridCol>
    <GridCol Span="6">
        <div style="@_style">@Count @L["Items"]</div>
    </GridCol>
    <GridCol Span="6">
        <div style="@_style">
            @if (!HideNsSelector)
            {
                <NamespaceSelect OnNsSelected="OnNsSelectedHandler"></NamespaceSelect>
            }
        </div>
    </GridCol>
    <GridCol Span="5">
        <div style="@_style">
            <Search Placeholder="@($"{L["Search"]} {Title}")" OnSearch="@OnSearchHandler" OnChange="@OnSearchHandler" @bind-Value="@TxtValue" AllowClear EnterButton="@("Search")" ClassicSearchIcon/>
        </div>
    </GridCol>
    <GridCol Span="1"></GridCol>
</GridRow>

@ChildContent

@if (TableData?.SelectedRows?.Count() > 0)
{
    <GridRow Class="grid-table">
        <GridCol Span="2">
            @L["Action"]:
        </GridCol>
        <GridCol Span="4">
            @if (TableData?.SelectedRows?.Count() > 0)
            {
                <Popconfirm Title="@L["Delete"]" OnConfirm="@DeleteHandler">
                    <Button Type="@ButtonType.Primary" Danger Size="small">@L["Delete"]</Button>
                </Popconfirm>

                <Button Size="small" OnClick="@RemoveAllSelectedHandler">@L["UnSelect"]</Button>
            }
        </GridCol>
        <GridCol Span="2">
            @if (TableData?.SelectedRows?.Count() > 0)
            {
                @($"{@L["Selected"]}({TableData.SelectedRows.Count()}):")
            }
        </GridCol>
        <GridCol Span="15">
            @if (TableData?.SelectedRows?.Count() > 0)
            {
                @foreach (var selected in TableData.SelectedRows)
                {
                    <Tag @key="selected" Closable OnClose="@(() => CloseSelectedItemHandler($"{selected.Namespace()}/{selected.Name()}"))">@selected.Name()</Tag>
                }
            }
        </GridCol>
    </GridRow>
}
